/**
 * Created by 魏爷 on 2016/6/3.
 */
$(function(){
    var url=$('#go-url').val();
    var out_url=$('#out-url').val();
    var app={
        go:function(obj){
            var loading=layer.load(1);
            $.post(
                url,
                {borrow_id:obj.attr('go-id'),book_id:obj.attr('book-id')},
                function(res){
                    layer.close(loading);
                    if(res.status==1){
                        layer.msg(res.info,{icon:1});
                        window.location.reload();
                    }else{
                        layer.msg(res.info,{icon:2});
                        window.location.reload();
                    }
                });
        },

        out:function(obj){
            var loading=layer.load(1);
            $.post(
                out_url,
                {borrow_id:obj.attr('out-id')},
                function(res){
                    layer.close(loading);
                    if(res.status==1){
                        layer.msg(res.info,{icon:1});
                        window.location.reload();
                    }else{
                        layer.msg(res.info,{icon:2});
                        window.location.reload();
                    }
                });
        },
    }
    $('.go').click(function () {
        app.go($(this));
    });
    $('.out').click(function () {
        app.out($(this));
    });
});
